var express = require('express')
var router = express.Router();
const { register, login } = require('../../service/people/loginService');
const bcryptjs = require('bcryptjs')

// 注册
router.post('/register', async function (req, res, next) {
    //console.log(req.body)
    const { newname, newpass, nickname } = req.body;
   // console.log(newname, newpass, nickname);
    const newPass = bcryptjs.hashSync(newpass, 8)
    const data = await register({ newname, newPass, nickname });
    console.log('用户注册第一层', data)
    res.send(data);
})
// 登录
router.post('/login', async function (req, res, next) {
    const { loginName, loginPass } = req.body;
    const data = await login({ loginName, loginPass });
   // console.log('用户登录第一层', data);
    res.send(data);
})
module.exports = router